require 'test/unit'
require 'Modele/Parking'
require 'Modele/Vehicule'
require 'Modele/Dbconect'

class ParkingTest < Test::Unit::TestCase
  
  def test_nombre_place
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    assert parking.nbPlace==3
    assert parking.nbDispo==3
  end
  
  def test_parking_plein
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    vehicule= Vehicule.new("123ABC31",1.5,3.2)
    vehicule2= Vehicule.new("123ABC75",1.5,3.2)
    vehicule3= Vehicule.new("123ABC76",1.5,3.2)    
    parking.acces[0].borne.delivrer_ticket(vehicule,nil)
    parking.acces[0].borne.delivrer_ticket(vehicule2,nil)
    parking.acces[0].borne.delivrer_ticket(vehicule3,nil)
    assert(parking.est_plein(),"test_parking_plein fail")
  end
  
def test_place_libre
    Dbconect.creationbd("test")
    parking = Parking.new("test",3)
    vehicule= Vehicule.new("123ABC31",1.5,3.2)    
    parking.acces[0].borne.delivrer_ticket(vehicule,nil)
    assert(parking.place_libres(nil) != nil,"test_place_libres")
  end
  
end